 <?php
 /**
  * 
  * @author HZ_02
  * 统计实体类
  */
class TotalAction extends CommonAction{
	
	/**
	 * 数据分享统计
	 * @param int       num      天数(默认为7天)
	 * @param string    type     时间类型[hour,day[默认],week,month,year]
	 *
	 */
	public function share_index(){
		$num  = $this->_param("num","intval",7);
		$maps['num']  = $num;
		$maps['type'] = "day";
		
		$json = sendRest("Total/behavior_index",$maps);
	/* 		dump($json);
			exit(); */
		$this->assign("detail",$json['data']);
		$this->assign("today", date("m-d"));
		$this->assign("yesday",date("m-d",time()-86400));
		$this->display();
	}
	
	/**
	 * 行为统计
	 * @param int       num      天数(默认为7天)
	 * @param string    type     时间类型[hour,day[默认],week,month,year]
	 *
	 */
	public function behavior_index(){
		$num  = $this->_param("num","intval",7);
		$maps['num']  = $num;
		$maps['type'] = "day";
	
		$json = sendRest("Total/behavior_index",$maps);
		/* 		dump($json);
		 exit(); */
		$this->assign("detail",$json['data']);
		$this->assign("today", date("m-d"));
		$this->assign("yesday",date("m-d",time()-86400));
		$this->display();
	}
	
	/**
	 * 数据分享统计
	 * 图表json
	 */
	public function share_chart(){

		$userid = $this->_get("userid","intval",0);
		if($userid){
			$maps['userid'] = $userid;
		}
		
		$type   = $this->_param("type","trim","day");
		$func   = $this->_param("func","trim","timeamount");
		
		$maps['type'] = $type;
		$maps['func'] = $func;
		if($func == "timeamount"){
			$maps['num'] = $this->_param("num","intval",5);
		}else{
			$maps['start'] = $this->_param("start","trim","");
			$maps['end']   = $this->_param("end","trim","");
		}
		
		$json = sendRest("Total/share_chart",$maps);
		$this->ajaxReturn($json['data']);
	}
	
	/**
	 * 用户数据分享统计
	 
	public function share_user(){
		
		$id    = $this->_param("id","trim",0);
		$model = M("Member");
		$rows  = $model->find($id);
		$this->assign("user",$rows);
		
		$num  = $this->_param("num","intval",7);
		$maps['num']    = $num;
		$maps['userid'] = $rows['userid'];
		$maps['type']   = "day";
	
		$json  = sendRest("Total/behavior_index",$maps);
		
		$this->assign("detail",$json['data']);
		$this->assign("today", date("m-d"));
		$this->assign("yesday",date("m-d",time()-86400));
	
		$this->display();
	}*/
	
	/**
	 * 数据跟踪用户浏览列表
	 */
	public function user_scan(){
		
		$date = $this->_get("date");
		
		if($date){
			$start = strtotime(date("Y")."-".$date);
			$end   = $start+86400;
			$map['addtime'] = array(array("egt",$start),array("lt", $end),"and");
		}
		
		$map['type'] = 1 ;
		$model = M("ShareLog");
		$list  = $model->where($map)->select();
		$this->assign("list",$list);
		
		$this->display();
	}
	
	/**
	 * 数据跟踪用户注册列表
	 */
	public function user_reg(){
		
		if($date){
			$start = strtotime(date("Y")."-".$date);
			$end   = $start+86400;
			$map['addtime'] = array(array("egt",$start),array("lt", $end),"and");
		}
		
		$map['type'] = 5 ;
		$list =M("ShareLog")->where($map)->select();
		$this->assign("list",$list);
		
		$this->display();
	}
}
?>